package shop

import (
	"context"
	"fast-boot/app/api/admin/internal/svc"
	"fast-boot/app/api/admin/internal/types"
	"fast-boot/app/model"

	"github.com/zeromicro/go-zero/core/logx"
)

type OptionsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 店铺下拉列表
func NewOptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OptionsLogic {
	return &OptionsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *OptionsLogic) Options() (resp []*types.ShopOptionItem, err error) {

	var items []*types.ShopOptionItem
	l.svcCtx.GormClient.GormDb.Model(model.PmsShopModel{}).
		Select("id as value", "name as label ").
		Where("status = 1").
		Order("id asc ").
		Scan(&items)

	return items, nil
}
